#include <iostream>

using namespace std;

struct node{
    char num;
    string s;
}a[30];

int main()
{
    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i].num;
    for(int i = 1; i <= n; i++) cin >> a[i].s;
    char ans;
    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        string s = a[i].s;
        string tmp;
        for(auto ch : s)
        {
            if(ch == '/') break;
            else tmp += ch;
        }
        int t = stoi(tmp);
        if(t > cnt)
        {
            cnt = t;
            ans = a[i].num;
        }
    }
    cout << ans << endl;
    return 0;
}